<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../../Site/static/js/crypto-js-3.1.9-1/crypto-js.js"></script>
    <script src="../../Site/static/js/jquery-3.3.1.js"></script>
</head>
<body>
<script>
    $(document).ready(function () {
        var key = "12345678"     //秘钥必须为：8/16/32位
        var message = "hello";

        //加密
        var encrypt = CryptoJS.AES.encrypt(message, CryptoJS.enc.Utf8.parse(key), {
            mode: CryptoJS.mode.ECB,
            padding: CryptoJS.pad.Pkcs7
        });
        console.log("value: " + encrypt);

        encrypt = "ngw9fgkqCJFyjI/fXuHCkw==";

        //解密
        var decrypt = CryptoJS.AES.decrypt(encrypt, CryptoJS.enc.Utf8.parse(key), {
            mode: CryptoJS.mode.ECB,
            padding: CryptoJS.pad.Pkcs7
        });
        console.log("value: " + decrypt.toString(CryptoJS.enc.Utf8));
    })
</script>
</body>
</html>